package com.cloudsigns.factorymanager2.project.presenter;

import com.cloudsigns.factorymanager2.project.iview.ISurveyOrderReceiveOrBackForTeamView;
import com.cloudsigns.factorymanager2.project.model.ISurveyOrderReceiveOrBackForTeamModel;
import com.cloudsigns.factorymanager2.project.model.SurveyOrderReceiveOrBackForTeamModel;

/**
 * Created by tony on 2018/8/5.
 */

public class SurveyOrderReceiveOrBackForTeamPresenter {
    private ISurveyOrderReceiveOrBackForTeamView view;
    private ISurveyOrderReceiveOrBackForTeamModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public SurveyOrderReceiveOrBackForTeamPresenter(ISurveyOrderReceiveOrBackForTeamView view) {
        this.view = view;
        this.model = new SurveyOrderReceiveOrBackForTeamModel();
    }

    public void surveyOrderReceiveOrBackForTeam() {


        model.surveyOrderReceiveOrBackForTeam(view.getOrderId(), view.getStatus(), new  SurveyOrderReceiveOrBackForTeamModel.OnSurveyOrderReceiveOrBackForTeamListener() {
            @Override
            public void surveyOrderReceiveOrBackForTeamSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.surveyOrderReceiveOrBackForTeamSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void surveyOrderReceiveOrBackForTeamfailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.surveyOrderReceiveOrBackForTeamFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
